package com.ruoyi.washer.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.washer.domain.XwEnduserTeam;
import com.ruoyi.washer.service.IXwEnduserTeamService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 终端团队Controller
 * 
 * @author hawking
 * @date 2023-12-26
 */
@RestController
@RequestMapping("/washer/team")
public class XwEnduserTeamController extends BaseController
{
    @Autowired
    private IXwEnduserTeamService xwEnduserTeamService;

    /**
     * 查询终端团队列表
     */
    @PreAuthorize("@ss.hasPermi('washer:team:list')")
    @GetMapping("/list")
    public TableDataInfo list(XwEnduserTeam xwEnduserTeam)
    {
        startPage();
        List<XwEnduserTeam> list = xwEnduserTeamService.selectXwEnduserTeamList(xwEnduserTeam);
        return getDataTable(list);
    }

    /**
     * 导出终端团队列表
     */
    @PreAuthorize("@ss.hasPermi('washer:team:export')")
    @Log(title = "终端团队", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, XwEnduserTeam xwEnduserTeam)
    {
        List<XwEnduserTeam> list = xwEnduserTeamService.selectXwEnduserTeamList(xwEnduserTeam);
        ExcelUtil<XwEnduserTeam> util = new ExcelUtil<XwEnduserTeam>(XwEnduserTeam.class);
        util.exportExcel(response, list, "终端团队数据");
    }

    /**
     * 获取终端团队详细信息
     */
    @PreAuthorize("@ss.hasPermi('washer:team:query')")
    @GetMapping(value = "/{teamId}")
    public AjaxResult getInfo(@PathVariable("teamId") Long teamId)
    {
        return success(xwEnduserTeamService.selectXwEnduserTeamByTeamId(teamId));
    }

    /**
     * 新增终端团队
     */
    @PreAuthorize("@ss.hasPermi('washer:team:add')")
    @Log(title = "终端团队", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XwEnduserTeam xwEnduserTeam)
    {
        return toAjax(xwEnduserTeamService.insertXwEnduserTeam(xwEnduserTeam));
    }

    /**
     * 修改终端团队
     */
    @PreAuthorize("@ss.hasPermi('washer:team:edit')")
    @Log(title = "终端团队", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XwEnduserTeam xwEnduserTeam)
    {
        return toAjax(xwEnduserTeamService.updateXwEnduserTeam(xwEnduserTeam));
    }

    /**
     * 删除终端团队
     */
    @PreAuthorize("@ss.hasPermi('washer:team:remove')")
    @Log(title = "终端团队", businessType = BusinessType.DELETE)
	@DeleteMapping("/{teamIds}")
    public AjaxResult remove(@PathVariable Long[] teamIds)
    {
        return toAjax(xwEnduserTeamService.deleteXwEnduserTeamByTeamIds(teamIds));
    }
}
